package com.newstar.service.impl;

import com.newstar.mapper.TbItemMapper;
import com.newstar.pojo.TbItem;
import com.newstar.pojo.TbItemExample;
import com.newstar.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemServiceImpl implements ItemService {

    @Autowired
    private TbItemMapper tbItemMapper;
    @Override
    public TbItem getItemById(Long itemId) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(itemId);
        System.out.println("后端接收到千秋开始查询"+itemId);
        List<TbItem> tbItemList = tbItemMapper.selectByExample(example);
        if(tbItemList.size()>0){
            return tbItemList.get(0);
        }else {
            return null;
        }
    }
}
